<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>手续费配置管理</title>
    <%@ include file="/view/common/tags.jsp"%>
    <style type="text/css">
        .fixed-table-container thead th .th-inner{
        line-height: 12px;
    </style>
</head>
<body>
<section class="content">
    <div class="row">
        <div class="col-md-12">
            <div class="box">
                <div class="box-body">
                    <div class="panel panel-default">
                        <div class="panel-body" style="padding-bottom:5px;">
                            <form class="form-horizontal" action="" method="post" id="dataForm">
                                <div class="searchMenu">
                                    <div>
                                        <label>游戏：</label>
                                        <sk:select cssClass="form-control select" id="gameId" name="wm[GAME_ID]" value="${page.wm.GAME_ID}" requiredInit="true" ajaxURL="${userInfoV1}/baseGame/gameSelect?wm[DEL_FLAG]=1" onchange="TagUtil.fillOptions('gameId');">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>区：</label>
                                        <sk:select cssClass="form-control select" id="areaId" name="wm[AREA_ID]" value="${page.wm.AREA_ID}" ajaxURL="${userInfoV1}/baseArea/select?wm[DEL_FLAG]=1" parentCascadedSelect="gameId" parentParamName="gameId" onchange="TagUtil.fillOptions('areaId');" >
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>服：</label>
                                        <sk:select cssClass="form-control select" id="serverId" name="wm[SERVER_ID]" value="${page.wm.SERVER_ID}" ajaxURL="${userInfoV1}/baseServer/select?wm[DEL_FLAG]=1" parentCascadedSelect="areaId" parentParamName="areaId">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                </div>
                                
                                <div class="searchMenu" style="width: 100%; float: left;">
                                    <div>
                                        <label>商品基类：</label>
                                        <sk:select cssClass="form-control select" id="typeFlag" name="wm[TYPE_FLAG]" value="${page.wm.TYPE_FLAG}" parentCascadedSelect="gameId" parentParamName="wm[GAME_ID]" ajaxURL="${userInfoV1}/gameGoodsType/baseTypeSelect?wm[DEL_FLAG]=0" onchange="setAjxaUrl('goodsBigId', 'gameId'); TagUtil.fillOptions('typeFlag');">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>商品大类：</label>
                                        <sk:select cssClass="form-control select" id="goodsBigId" name="wm[GOODS_BIG_ID]" value="${page.wm.GOODS_BIG_ID}" parentCascadedSelect="typeFlag" parentParamName="wm[TYPE_FLAG]" ajaxURL="${userInfoV1}/gameGoodsType/typeSelect?wm[DEL_FLAG]=0" onchange="setAjxaUrl('goodsSmallId', 'gameId'); TagUtil.fillOptions('goodsBigId')">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>商品小类：</label>
                                        <sk:select cssClass="form-control select" id="goodsSmallId" name="wm[GOODS_SMALL_ID]" value="${page.wm.GOODS_SMALL_ID}" parentCascadedSelect="goodsBigId" parentParamName="wm[PARENT_ID]" ajaxURL="${userInfoV1}/gameGoodsType/smallTypeSelect?wm[DEL_FLAG]=0">
                                            <option  value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <div>
                                        <label>交易类型：</label>
                                        <sk:select cssClass="form-control select" id="tradeId" name="wm[TRADE_ID]" value="${page.wm.TRADE_ID}" parentCascadedSelect="gameId" parentParamName="gameId" requiredInit="true" ajaxURL="${tradeV1}/tradeState/gameTradeTypeDictList">
                                            <option value="">请选择</option>
                                        </sk:select>
                                    </div>
                                    <button type="button" class="btn btn-primary btn-sm" style="margin-left: 20px;" onclick="findData()"><span class='glyphicon glyphicon-search'></span>查&nbsp;询</button>
                                    <div style="float:right;">
                                        <sk:button type="button"  rightKey="20170816153238"  _class="btn btn-success btn-sm"  onclick="add()"><span class='glyphicon glyphicon-plus'></span>添&nbsp;加</sk:button>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                    <table class="table table-hover table-condensed table-bordered table-striped" id="dataTable" >
                        <thead>
                            <tr>
                                <th data-field="index" rowspan="2" data-align="center" data-formatter="indexFormatter" data-sortable="false">序号</th>
                                <th data-field="feePackageName" rowspan="2" data-align="center" data-sortable="true">套餐名称</th>
                                <th data-field="gameName" rowspan="2" data-align="center" data-sortable="true">游戏名称</th>
                                <th data-field="areaName" rowspan="2" data-align="center" data-sortable="true">区名称</th>
                                <th data-field="serverName" rowspan="2" data-align="center" data-sortable="true">服名称</th>
                                <th data-field="typeName" rowspan="2" data-align="center" data-sortable="true">商品基类</th>
                                <th data-field="goodsBigName" rowspan="2" data-align="center" data-sortable="true">商品大类</th>
                                <th data-field="goodsSmallName" rowspan="2" data-align="center" data-sortable="true">商品小类</th>
                                <th data-field="tradeName" rowspan="2" data-align="center" data-sortable="true">交易类型</th>
                                <th data-field="minSalePrice" rowspan="2" data-align="center">最低发布额</th>
                                <th colspan="2" data-align="center" class="tableTh">(最低-中间)区间手续费</th>
                                <th data-field="midSalePrice" rowspan="2" data-align="center">中间发布额</th>
                                <th colspan="2" data-align="center">(中间-最高)区间手续费</th>
                                <th data-field="maxSalePrice" rowspan="2" data-align="center">最高发布额</th>
                                <th data-field="maxFee" rowspan="2" data-align="center">最高手续费</th>
                                <th data-field="deleteButton" rowspan="2" data-align="center" data-formatter="buttonFormatter" data-sortable="false">操作</th>
                            </tr>
                            <tr>
                                <th data-field="minFeeRate" data-align="center">费率</th>
                                <th data-field="minFee" data-align="center">附加手续费</th>
                                <th data-field="midFeeRate" data-align="center">费率</th>
                                <th data-field="midFeeAppend" data-align="center">附加手续费</th>
                            </tr>
                        </thead>
                    </table>
                </div>
            </div>
        </div>
    </div>
</section>
<%@ include file="/view/common/footer.jsp"%>
</body>
<script>
    // 提示信息
    var msgg='<%=request.getAttribute("msg")%>';
    if (msgg && msgg!=null && msgg!='null') {
        layer.msg(msgg);
    }

    function buttonFormatter(value, row, index) {
        var caozuo1 = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
        //var caozuo2 = "<button id='btn_edit' type='button' onclick='deletePublishNum("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-remove'></span>&nbsp;删&nbsp;除&nbsp;</button>";
        return caozuo1;
    }

    // 加载table 数据
    $(function(){
        $("#dataTable").bootstrapTable({
            url: "${tradeV1}/tradeBasePackageFeeDetail/getPackageFeeDetailList",
            method:"get",
            contentType: "application/x-www-form-urlencoded",
            pagination:true,
            sidePagination:"server",
            queryParams: function(params) {
                return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));
            }
        });
    })

    var tableIndex = 0;
    // 弹出添加的窗口
    function add(){
        tableIndex = layer.open({
            type: 2,
            title: "添加手续费配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['780px', '470px'],
            content: '${sysManagerV1}/baseTradeSxFee/toAdd?rowId=0',
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }
    // 弹出添加的窗口      修改功能
    function _update(rowId){
        tableIndex = layer.open({
            type: 2,
            title: "修改手续费配置",
            closeBtn: 1,
            shadeClose: true,
            area: ['780px', '470px'],
            content: '${sysManagerV1}/baseTradeSxFee/toAdd?rowId='+rowId,
            btn: ["确 认","关 闭"],
            yes: function(index, layero){
                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
                iframeWin.add();
            }
        });
    }

    //查询
    function findData(){
        $("#dataTable").bootstrapTable("refresh",{} );
    }

    /*bootstrap table点击行事件*/
    $(function(){
        $("body").on("click","table>tbody>tr",function(){
            $(this).css("background","#e1ecf1").siblings().css("background","");
        });
    });

    //给目标select的ajaxURL 加参数
    function setAjxaUrl(keyId, valueId){
        var gameId = $("#" + valueId).find("option:selected").val();
        var ajaxURL = $("#" + keyId).attr("ajaxURL");
        if(ajaxURL.indexOf("GAME_ID") < 0){
            ajaxURL += "&wm[GAME_ID]=" + gameId;
        } else {
            var valueTemp = ajaxURL.substring(ajaxURL.indexOf("wm[GAME_ID]="));
            if(valueTemp.indexOf("&") >= 0){
                valueTemp = valueTemp.substr(valueTemp.indexOf("=") + 1, valueTemp.indexOf("&"));
            }
            ajaxURL = ajaxURL.replace(valueTemp, "wm[GAME_ID]=" + gameId);
        }
        $("#" + keyId).attr("ajaxURL", ajaxURL);
    }
</script>
</html>